import { BaseWindow } from "../../../component/window/BaseWindow";
import { GlobalClass } from "../../../../com/mui/core/GlobalClass";
import { ImagesConst } from "../../resource/ImagesConst";
import { AIManager } from "../../scene/ai/AIManager";
import { AIType } from "../../scene/ai/AIType";
import { TaskTargetInfo } from "../../model/TaskTargetInfo";
import { HTMLUtil } from "../../../../com/gengine/utils/HTMLUtil";
import { Language } from "../../../../extend/language/Language";
import { ColorConfig } from "../../resource/ColorConfig";
import { ResouceConst } from "../../../component/gconst/ResouceConst";
import { GTextFormat } from "../../../common/GTextFormat";
import { FontUtil } from "../../../common/font/FontUtil";
import { GButton } from "../../../../com/mui/controls/GButton";
import { ScaleBitmap } from "../../../../com/mui/display/ScaleBitmap";
//class TransportNPCGuide
    
    export  class TransportNPCGuide extends BaseWindow
    {
        constructor()
        {
            super();
            setSize(300, 150);
            title = GlobalClass.getBitmap(ImagesConst.Title_Tips);
            return;
        }

        /* internal  */onGotoBtnClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            AIManager.onAutoPathAIControl(this._targetInfo);
            hide();
            return;
        }

        /* internal  */onFlyBtnClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            AIManager.onAIControl(this._targetInfo, AIType.AI_Convey);
            hide();
            return;
        }

        public updateData(arg1: TaskTargetInfo): void
        {
            this._targetInfo = arg1;
            this._infoTxt.htmlText = HTMLUtil.addColor("  " + Language.getStringByParam(20750, "<u><a href=\'event: 0\'>" + HTMLUtil.addColor(arg1.mapName, ColorConfig.instance.getTaskColor("map_name").color) + "-" + HTMLUtil.addColor(arg1.name, ColorConfig.instance.getTaskColor("entity_name").color) + "(" + arg1.x + "，" + arg1.y + ")</a></u>"), "#ffffff");
            return;
        }

        protected /* override */ createChildren(): void
        {
            super.createChildren();
            this._middleBg = ResouceConst.getScaleBitmap(ImagesConst.WindowCenterB);
            addChild(this._middleBg);
            this._infoTxt = new Object /* flash.text.TextField */();
            this._infoTxt.defaultTextFormat = new GTextFormat(FontUtil.songtiName, 12, 16777215, null, null, null, null, null, flash.text.TextFormatAlign.LEFT, null, null, null, 8);
            this._infoTxt.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._infoTxt.selectable = false;
            this._infoTxt.multiline = true;
            this._infoTxt.wordWrap = true;
            addChild(this._infoTxt);
            this._infoTxt.addEventListener(flash.events.MouseEvent.CLICK, this.onGotoBtnClickHandler);
            this._gotoBtn = new GButton();
            this._gotoBtn.label = Language.getString(20751);
            this._gotoBtn.styleName = "Button";
            this._gotoBtn.setSize(80, 26);
            addChild(this._gotoBtn);
            this._gotoBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onGotoBtnClickHandler);
            this._flyBtn = new GButton();
            this._flyBtn.label = Language.getString(20752);
            this._flyBtn.styleName = "Button";
            this._flyBtn.setSize(80, 26);
            addChild(this._flyBtn);
            this._flyBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onFlyBtnClickHandler);
            return;
        }

        protected /* override */ updateSize(): void
        {
            titleHeight = 25;
            super.updateSize();
            title.y = 10;
            this._middleBg.width = this.width - 25;
            this._middleBg.height = this.height - 46;
            this._middleBg.x = 12;
            this._middleBg.y = 36;
            this._infoTxt.x = this._middleBg.x + 10;
            this._infoTxt.y = this._middleBg.y + 30;
            this._infoTxt.width = this._middleBg.width - 20;
            this._gotoBtn.x = width / 2 - this._gotoBtn.width - 20;
            this._gotoBtn.y = height - this._gotoBtn.height - 15;
            this._flyBtn.x = width / 2 + 20;
            this._flyBtn.y = height - this._flyBtn.height - 15;
            return;
        }

        /* internal */ /* var */_middleBg: ScaleBitmap;

        /* internal */ /* var */_gotoBtn: GButton;

        /* internal */ /* var */_flyBtn: GButton;

        /* internal */ /* var */_infoTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_targetInfo: TaskTargetInfo;
    }
